package com.service.impl;

import com.dao.ParkDao;
import com.pojo.ParkingLot;
import com.service.ParkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ParkServiceImlp implements ParkService {
    @Autowired
    private ParkDao parkDao;

    @Override
    public List<ParkingLot> findALL() {

        System.out.println("进入到了Service层的findALL...");

        List<ParkingLot> parkingLots = parkDao.selectList(null);

        parkingLots.forEach(System.out::println);

        System.out.println("执行完了Service层的findALL...");
        return parkingLots;
    }

    @Override
    public List<ParkingLot> findByAddress(int address) {

        System.out.println("开始执行了Service层的findByAddress...");
        List<ParkingLot> parkingLots = null;

        Map<String, Object> map = new HashMap<>();

        switch (address) {
            case 1: {
                System.out.println("执行了A区");
                map.put("address", "A区");
                parkingLots = parkDao.selectByMap(map);

                break;
            }
            case 2: {
                System.out.println("执行了B区");

                map.put("address", "B区");
                parkingLots = parkDao.selectByMap(map);
                break;
            }
            case 3: {
                System.out.println("执行了C区");

                map.put("address", "C区");
                parkingLots = parkDao.selectByMap(map);
                break;
            }
            default: {

                System.out.println("执行了default");
                System.out.println("哥们别输错了");

            }
        }
        
        return parkingLots;
    }

}
